#include "behavior_tree_parallel_policy.h"
#include <behaviortree_cpp_v3/controls/parallel_node.h>

namespace policy
{
BehaviorTreeParallelPolicy::BehaviorTreeParallelPolicy(const std::string &name)
    : BehaviorTreePolicy(name)
{
    policy_tree_node_ = std::make_unique<BT::ParallelNode>(name + "_parallel_node", 1);
}
void BehaviorTreeParallelPolicy::setSuccessThreshold(int count)
{
    auto *node = dynamic_cast<BT::ParallelNode *>(policy_tree_node_.get());
    if (nullptr == node)
    {
        EASE_ERROR("parallel node dynamic_cast error");
        return;
    }
    node->setSuccessThreshold((int) node->childrenCount());
}
BehaviorTreeParallelPolicy::~BehaviorTreeParallelPolicy() = default;
}
